package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tanhua.dubbo.api.BlackListApi;
import com.tanhua.model.db.UserInfo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @auther : 白月尘
 * @date : 14:09  2021/10/18
 */
@Service
public class BlackListService {
    @DubboReference
    private BlackListApi blackListApi;

    /**
     *
     * @param uid
     */
    public void deleteBlackList(long uid) {
        long userId = UserHolder.getUserId();
        blackListApi.deleteBlackList(userId,uid);
    }

    /**
     *
     * @param page
     * @param pageSize
     * @return
     */
    public PageResult blacklist(int page, int pageSize) {
        long userId = UserHolder.getUserId();
        IPage<UserInfo> iPage = blackListApi.blacklist(page, pageSize, userId);
        PageResult pageResult=new PageResult(page,pageSize,iPage.getTotal(),iPage.getRecords());
        return pageResult;
    }
}
